import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;



public class testrps {
	
	public testrps()
	{
		
	}

	private RockPaperScissors rps;
	private Player p1,p3,p4,p5,p6;
	private Player p2;
	private RPSEnum[] p1enum ;
	private RPSEnum[] p2enum ;
	private RPSEnum[] p3enum ;

	@BeforeClass 
	void setUpClass()
	{
		p1enum = new RPSEnum[2];
		p1enum[0] = RPSEnum.valueOf("PAPER");
		p1enum[1] = RPSEnum.valueOf("ROCK");

		p2enum = new RPSEnum[2];
		p2enum[0] = RPSEnum.valueOf("ROCK");
		p2enum[1] = RPSEnum.valueOf("ROCK");		
		
		p3enum = new RPSEnum[2];
		p3enum[0] = RPSEnum.valueOf("ROCK");
		p3enum[1] = RPSEnum.valueOf("PAPER");
		rps = new RockPaperScissors();
		
		//win
		p1 = new Player("nom1",p1enum);
		p2 = new Player("nom2",p2enum);
		
		//lose
		p3 = new Player("nom1",p2enum);
		p4 = new Player("nom2",p1enum);
		
		//tie
		p5 = new Player("nom1",p1enum);
		p6 = new Player("nom2",p3enum);
	}
	
	@AfterClass
	void tearDownClass()
	{
		rps = null;
		p1 = null;
		p2 = null;
	}

	@DataProvider(name = "failed")
	public Object[][] failed() {
	return new Object[][]
			{
				{"ROCK", "PAPER"},
				{"PAPER", "SCISSORS"},
				{"SCISSORS", "ROCK"},
			};
	}

	@DataProvider(name = "success")
	public Object[][] success() {
	return new Object[][]
			{
				{"PAPER", "ROCK"},
				{"SCISSORS", "PAPER"},
				{"ROCK", "SCISSORS"},
			};
	}
	
	
	@DataProvider(name = "tie")
	public Object[][] tie() {
	return new Object[][]
			{
				{"PAPER", "PAPER"},
				{"SCISSORS", "SCISSORS"},
				{"ROCK", "ROCK"},
			};
	}
	
	@DataProvider(name = "playertestwin")
	public Object[][] playertestwin() {
	return new Object[][]
			{
				{p1, p2},
			};
	}
	
	@DataProvider(name = "playertestlose")
	public Object[][] playertestlose() {
	return new Object[][]
			{
				{p3, p4},
			};
	}
	
	@DataProvider(name = "playertesttie")
	public Object[][] playertesttie() {
	return new Object[][]
			{
				{p5, p6},
			};
	}
	
	@Test(dataProvider = "playertesttie")
	void testtiePlayer(@Optional Player p1,@Optional  Player p2)
	{
		Assert.assertEquals(rps.player(p1, p2), Result.TIE);
	}
	
	@Test(dataProvider = "playertestwin")
	void testwinPlayer(@Optional Player p1,@Optional  Player p2)
	{
		Assert.assertEquals(rps.player(p1, p2), Result.WIN);
	}
	
	@Test(dataProvider = "playertestlose")
	void testlosePlayer(@Optional Player p1,@Optional  Player p2)
	{
		Assert.assertEquals(rps.player(p1, p2), Result.LOST);
	}
	
	@Test(dataProvider = "success")
	void testWinPlay(@Optional String p1,@Optional  String p2)
	{
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)), Result.WIN);
	}

	@Test(dataProvider = "failed")
	void testlosePlay(@Optional String p1,@Optional  String p2)
	{
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)), Result.LOST);
	}
	
	@Test(dataProvider = "tie")
	void testtiePlay(@Optional String p1,@Optional  String p2)
	{
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)), Result.TIE);
	}
	
}
